import { DEFAULT_OPTS } from '@/settings'
import { defHttp } from '@/utils/http/axios'
import { IAddUser, IUpdatePassword, IUserBindStore, IUserInfo } from './model'

enum API {
  USER = '/user/info',
  USER_LIST = '/user/list',
  USER_ADD = '/user/',
  USER_UPDATE_PWD = '/user/pwd',
  USER_BIND_STORE = '/user/bindStore'
}

/** 修改用户信息 */
export function updateUserInfo(data: IUserInfo) {
  return defHttp.put({
    url: API.USER,
    data
  }, DEFAULT_OPTS)
}

/** 获取用户列表 */
export function getUserList() {
  return defHttp.get<IUserInfo[]>({
    url: API.USER_LIST
  }, DEFAULT_OPTS)
}

/** 新增用户 */
export function addUser(data: IAddUser) {
  return defHttp.post({
    url: API.USER_ADD,
    data
  }, DEFAULT_OPTS)
}

/** 修改密码  */
export function updatePassword(data: IUpdatePassword) {
  return defHttp.put({
    url: API.USER_UPDATE_PWD,
    data
  }, DEFAULT_OPTS)
}

/** 用户绑定门店 */
export function bindStoreWidthUser(data: IUserBindStore) {
  console.log(22222222, data)
  return defHttp.put({
    url: API.USER_BIND_STORE,
    data
  }, DEFAULT_OPTS)
}
